<!--  -->
<template>
  <div class="service-list">
    <template v-for="(item,index) in serviceList">
      <van-swipe-cell :key="index" class="">
        <router-link
          tag="div"
          :to="{name:'service',query:{shop_id:item.shop_id,id:item.id}}"
          class="service-item flex aligin-center"
        >
        <div class="img-wrapper">
           <img :src="item.shop_img" alt="">
           <span class="dot-img f-14 color-white" v-if="item.u_unread">{{item.u_unread}}</span>
        </div>
         
          <div class="ml-20 flex-1">
            <div class="flex justify-between">
              <span class="f-16">{{item.shop_name}}</span>
              <span class="color-gray f-14">{{item.last_time|changeTime}}</span>
            </div>
            <div
              class="f-14 mt-10 ellipsis h-18 color-gray"
            >{{item.last_content}}</div>
          </div>
        </router-link>
        <template slot="right">
          <span class="share flex justify-center aligin-center f-12">删除</span>
        </template>
      </van-swipe-cell>
    </template>
  </div>
</template>

<script>
import timeAgo from "../utils/date";
export default {
  props: {
    serviceList: {
      type: Array,
      default: () => {
        return [];
      },
      required: true
    }
  },

  filters: {
    //timeago.js插件
    //计算时间，类似于几分钟前，几小时前，几天前等
    changeTime(val) {
      return timeAgo(val);
    }
  },
  components: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {},
  created() {},
  mounted() {},
  updated() {}, //生命周期 - 更新之后
  destroyed() {} //生命周期 - 销毁完成
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.f-16 {
  font-size: 16px;
}
.h-18 {
  height: 24px;
  line-height: 24px;
  width: 250px;
}
.service-list {
  height: 100%;
  .service-item {
    padding: 0 20px;
    height: 80px;
    .img-wrapper{
      position: relative;
    }
    img {
      height: 60px;
      width: 60px;
      border-radius: 50%;
    }
    .dot-img{
      position: absolute;
      top: 0;
      right: 0;
      display: inline-block;
      padding: 4px 8px;
      background: rgba(247,88,151,1);
      border-radius: 50%;
    }
  }
  .flex-1 {
    flex: 1;
  }
}
.delete {
  display: inline-flex;
  height: 100%;
  width: 40px;
  background: #e5e5e5;
  color: #fff;
}
.share {
  display: inline-flex;
  height: 100%;
  width: 40px;
  background: #fe727b;
  color: #fff;
}
</style>